<template>
  <div class="flex gap-10px">
    <a-button type="primary" class="mb-15px" @click="showConfirm">导入字典</a-button>
  </div>
</template>

<script setup lang="ts">
import { message, Modal } from 'ant-design-vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { createVNode } from 'vue'

const showConfirm = () => {
  Modal.confirm({
    title: '这个操作很危险，确定要执行吗？',
    icon: createVNode(ExclamationCircleOutlined),
    content: createVNode(
      'div',
      { style: 'color:red;' },
      '希望你已经打开数据库的dev_dict表，并观察数据变化'
    ),
    onOk() {
      doImport()
    },
    onCancel() {
      console.log('Cancel')
    },
    class: 'test'
  })
}

const dbJson = {
  aaa: [
    {
      dictType: 'aaa',
      label: '劳动争议调委会',
      value: '1',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '设在信访部门调委会',
      value: '2',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '设在其他部门调委会',
      value: '3',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '学生伤害纠纷调委会',
      value: '4',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '知识产权纠纷调委会',
      value: '5',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '医疗纠纷调委会',
      value: '6',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '交通事故调委会',
      value: '7',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '物业纠纷调委会',
      value: '8',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '商会纠纷调委会',
      value: '9',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '银行业纠纷调委会',
      value: '10',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '海事渔事调委会',
      value: '11',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '其他调委会',
      value: '12',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '婚姻家庭纠纷调委会',
      value: '13',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '设在检察院调委会',
      value: '14',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '设在公安派出所调委会',
      value: '15',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '保险合同纠纷调委会',
      value: '16',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '消费纠纷调委会',
      value: '17',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '旅游纠纷调委会',
      value: '18',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '电子商务调委会',
      value: '19',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '设在法院调委会',
      value: '20',
      sort: '0'
    },
    {
      dictType: 'aaa',
      label: '环境污染纠纷调委会',
      value: '21',
      sort: '0'
    }
  ]
}

const doImport = () => {
  window.api.dictToDb(dbJson, (result) => {
    console.log(result)
    message.success('导入成功')
  })
}
</script>

<style lang="less" scoped>
:deep(.hljs span) {
  line-height: 20px;
}
</style>
